<template>
  <div class="list" ref="ha">
    <ul>
      <li @click="showList(value.id)" v-for="(value,index) in workList" :key="index">
        <div class="list_top">
          <div class="top_left">
            <div class="list_name substring" v-if="value.set_top==1"><span class="top_tag">[置顶]</span>{{value.job_type}}</div>
            <div class="list_name substring" v-if="value.set_top==0">{{value.job_type}}</div>
            <div class="list_details">
              <span class="details_type">{{value.type}}</span>
              <!-- <span class="details_type">{{value.trade_name}}</span> -->
              <span class="details_sex">{{value.sex}}</span>
            </div>
          </div>
          <div class="top_right">
            <div class="details_day">{{value.salary_type}}{{value.salary_num}}</div>
          </div>
        </div>
        <div class="list_center">
          <span class="details_city">{{value.province}}{{value.city==null? "" :value.city}}{{value.area==null? "" :value.area}}{{value.town==null? "" :value.town}}{{value.address_detail==null? "" :value.address_detail}}</span>
          <span class="details_number">{{value.people_num}}人</span>
        </div>
        <div class="list_center time">发布时间：{{value.updated_at}}</div>
        <div class="list_bottom" v-if="value.info">
          <img  :src="value.info.user_type=='personal' ?'http://file.rzkeji.com/web/recruit/icon/geren.png':'http://file.rzkeji.com/web/recruit/icon/qiye.png'" class="tag"/>
         <span v-if="value.info.user_type=='personal'">{{value.contact_name != null ? value.contact_name : "无"}}</span>
          <span v-if="value.info.user_type=='company'">{{value.info.company_info.name  != null ? value.info.company_info.name : "无"}}</span>
        </div>
        <div class="list_bottom" v-if="value.info">
          <div v-if="type=='people'?true : false" @click.stop="set_top(value.id)">{{value.set_top!='0' ?'置顶中' :'未置顶'}}</div>
          <div v-if="type=='people'?true : false" @click.stop="edit(value.id)">编辑</div>
          <div v-if="type=='people'?true : false" @click.stop="delete1(value.id)">删除</div>
          <div v-if="type=='people'?true : false" @click.stop="reset(value.id)">刷新职位</div>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
  import { Toast } from 'vant';
export default {
  props:['workList','type','tag'],

  methods:{
    showList(id){
      this.$router.push({ name: 'workDetail', params: { id: id }})
    },
    async reset(value){
        var userToken=window.localStorage.getItem('userToken')
        let data=await this.$axios.post('/position/reloadPosition',{user_token:userToken,id:value})
        console.log(data);
         Toast({message:data.data.message,duration:1000});
    },
    async delete1(value){
      let res=await this.$currency.showModal('','是否删除此纪录')
      if(res){
        var userToken=window.localStorage.getItem('userToken') 
        let data=await this.$axios.post('/ucenter/delMyPosition',{user_token:userToken,id:value})
        let status = this.tag=='end' ?"" :1;
        this.$emit('del',(status))
      }
    },
    edit(value){
      this.$router.push({name:'details',query:{id:value}})
    },
    set_top(value){
      this.$store.dispatch("setAdventType","position")
      this.$router.push({name:'payment',params:{id:value}})
    }
  }


}
</script>

<style scoped>
.list{margin:0 20px ;background-color:#fff;}
.list ul{width: 100%;}
.list ul li{width: 100%;background-color: #fff;margin-bottom: 5px;padding-top: 5px;}
.list_top{width: 100%;height: 62px;display: flex;justify-content: row;}
.top_left{width: 80%;}
.top_right{width: 25%;}
.list_name{width: 70%;font-size:17px;font-weight: 800;color: #484848; }
.list_details{width: 100%;height:100%;color: #6a6a6a;font-size: 13px;padding: 5px 0px;}
.list_details span{margin-right: 15px}
.details_money{color: #ff552e;font-size: 14px;text-align: right;}
.details_day{color: #999;font-size: 12px;margin-top:10px;text-align: right;}
.list_center{width: 300px;color: #999999;font-size: 12px;}
.list_center span{margin-right: 15px;}
.list_bottom{width: 340px;margin-top: 20px;display: flex;margin-bottom:5px;}
.list_bottom img{width: 30px;height: 15px;vertical-align: middle;}
.list_bottom span{font-size: 13px;color: #808080;margin-left:8px;}
/* .list_bottom span:nth-of-type(2){margin-left: 168px;} */
.list_bottom div{width: 70px;height: 30px;background-color: #38B4DB;color: #fff;border-radius: 7px;line-height: 30px;text-align: center;}
.list_bottom div:nth-of-type(2){width: 50px;background-color: #76B5FF;margin: 0px 5px;}
.list_bottom div:nth-of-type(3){width: 50px;background-color: #FF8A83;margin: 0px 5px;}
.list_bottom div:nth-of-type(4){width: 80px;background-color: #ff9d45}

li{border-bottom: 1px solid #eee}
.top_tag{color: red;font-weight: normal;font-size: 12px;margin-bottom: 5px}
.time{
  margin-top:10px;
}
</style>
